package com.bridgingcode.bankaccountscqrsdemo;

import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.security.NoTypePermission;
import org.axonframework.serialization.Serializer;
import org.axonframework.serialization.xml.XStreamSerializer;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Primary;
import org.springframework.core.env.Environment;
import org.springframework.core.env.Profiles;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.oas.annotations.EnableOpenApi;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.service.VendorExtension;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;

import java.util.ArrayList;

@SpringBootApplication
@EnableOpenApi
public class BankAccountsCqrsDemoApplication {

    public static void main(String[] args) {
        SpringApplication.run(BankAccountsCqrsDemoApplication.class, args);
    }

	@Bean
	public Docket docket(Environment environment) {
		// 设置了swagger的docket的环境
		boolean flag = environment.acceptsProfiles(Profiles.of("dev", "test", "prod"));

		return new Docket(DocumentationType.OAS_30)
				.apiInfo(apiInfo())
				.groupName("debited")
				.enable(true)
				.select()
				// 指定要扫描的包
				.apis(RequestHandlerSelectors.any())
				.build();
	}

	private ApiInfo apiInfo() {
		Contact contact = new Contact("authorName", "www.baidu.com", "111111@qq.com");

		return new ApiInfo("Api文档", "Api文档",
				"1.0", "www.baidu.com",
				contact, "Apache 2.0",
				"http://www.apache.org/licenses/LICENSE-2.0",
				new ArrayList<>());
	}

}
